/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package TweetRay;

import Raytracing.Shaders.Material;
import Raytracing.Shaders.Shader;
import processing.core.PGraphics3D;
import processing.core.PVector;

/**
 *
 *           __
 *          /  \
 *          ^  ^
 *         / \/ \
 *         | .| .|
 *         \_/\_/
 *          |  |
 *          \ o/
 *          /  \
 *         |    |
 *         | | ||
 *         | 0 0|
 *         |    |
 */
public abstract class Entity {

    protected float tx, ty, tz;
    protected boolean isSelected;
    protected int group = 0;

    public enum EntityTag {

        GROUND, NORMAL;
    }
    public EntityTag tag = EntityTag.NORMAL;

    public void setGroup(int group) {
        this.group = group;
    }

    public int getGroup() {
        return group;
    }
    Material[] shaders = null;
    protected int shaderIndex;

    public Entity() {
        isSelected = false;
    }

    public Entity(float tx, float ty, float tz) {

        this.tx = tx;
        this.ty = ty;
        this.tz = tz;

    }

    public void setSelected(boolean selected) {
        this.isSelected = selected;
    }

    public abstract void draw(PGraphics3D p3d);

    public abstract void pack(UTFWriter output);

    public abstract void scale(int axis, float amt);

    public void rotate(PVector origin, PVector dir, float amt) {
        PVector trans = new PVector(tx, ty, tz);
        trans.rotate(origin, dir, amt);

        tx = trans.x;
        ty = trans.y;
        tz = trans.z;


    }

    public abstract void setShader(int shaderIndex);

    public abstract Entity copy();

    public PVector getLocalXAxis(boolean normalized) {
        return new PVector(1, 0, 0);
    }

    public PVector getLocalYAxis(boolean normalized) {
        return new PVector(0, -1, 0);
    }

    public PVector getLocalZAxis(boolean normalized) {
        return new PVector(0, 0, 1);
    }

    public void translate(PVector dir) {
        /*
        if (tx + dir.x <= 255 && tx + dir.x >= 0) {
            tx += dir.x;
        }
        if (ty + dir.y <= 255 && ty + dir.y >= 0) {
            ty += dir.y;
        }
        if (tz + dir.z <= 255 && tz + dir.z >= 0) {
            tz += dir.z;
        }
         
         */
    }

    abstract public void pickDraw(PGraphics3D p3d, int index);

    public String toCode() {
        return "";
    }
}
